CC      = arm-linux-gcc
LD      = arm-linux-ld
AR      = arm-linux-ar
OBJCOPY = arm-linux-objcopy
OBJDUMP = arm-linux-objdump

INCLUDEDIR 	:= $(shell pwd)/include
CFLAGS 		:= -Wall -Os -fno-builtin
CPPFLAGS   	:= -nostdinc -I$(INCLUDEDIR)

export 	CC AR LD OBJCOPY OBJDUMP INCLUDEDIR CFLAGS CPPFLAGS 

objs := start.o  clock.o uart.o sdram.o main.o mmc.o mmu.o command.o shell.o lib/libc.a 

shell.bin: $(objs)
	${LD} -Tshell.lds -o shell.elf $^
	${OBJCOPY} -O binary -S shell.elf $@
	${OBJDUMP} -D shell.elf > shell.dis

.PHONY : lib/libc.a
lib/libc.a:
	cd lib; make; cd ..
	
%.o:%.c
	${CC} $(CPPFLAGS) $(CFLAGS) -c -o $@ $<

%.o:%.S
	${CC} $(CPPFLAGS) $(CFLAGS) -c -o $@ $<

clean:
	make  clean -C lib
	rm -f *.bin *.elf *.dis *.o *~
	
burn:
	cp *.bin ../2416.bin
	sudo ../hc_fusing_mmcboot.sh 
